package com.example.home.adapter

import com.chad.library.adapter.base.BaseProviderMultiAdapter
import com.example.home.adapter.provider.FollowCardProvider
import com.example.home.adapter.provider.SingleTitleProvider
import com.example.home.adapter.provider.TitleProvider
import com.example.home.adapter.provider.VideoCardProvider
import com.example.entity.BaseEntity
import com.example.home.R
import com.example.home.entity.viewdata.FollowCardViewData
import com.example.home.entity.viewdata.SingleTitleViewData
import com.example.home.entity.viewdata.TitleCardViewData
import com.example.home.entity.viewdata.VideoCardViewData

class NominateListAdapter : BaseProviderMultiAdapter<BaseEntity>() {


    init {
        addItemProvider(TitleProvider(NominateItemType.TITLE_VIEW, R.layout.item_home_title))
        addItemProvider(FollowCardProvider())
        addItemProvider(SingleTitleProvider())
        addItemProvider(VideoCardProvider(NominateItemType.VIDEO_CARD_VIEW, R.layout.item_video_card_view))

    }

    override fun getItemType(data: List<BaseEntity>, position: Int): Int {
        var entity= data[position]

        return when(entity){
            is TitleCardViewData -> NominateItemType.TITLE_VIEW
            is FollowCardViewData -> NominateItemType.FOLLOW_CARD_VIEW
            is SingleTitleViewData -> NominateItemType.SINGLE_TITLE_VIEW
            is VideoCardViewData -> NominateItemType.VIDEO_CARD_VIEW
            else -> NominateItemType.DEFAULT_VIEW
        }
    }
}